package com.pzy.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.pzy.dao.UserDao;
import com.pzy.domain.User;
import com.pzy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public boolean addUser(User user) {
        return userDao.addUser(user);
    }
    @Override
    public boolean deleteUser(Integer userID) {
        return userDao.deleteUser(userID);
    }
    @Override
    public boolean updateUser(User user) {
        return userDao.updateUser(user);
    }
    @Override
    public User getOne(Integer userID) {
        return userDao.getOne(userID);
    }
    @Override
    public PageInfo<User> getAll(int page, int size) {
        PageHelper.startPage(page,size);
        List<User> all = userDao.getAll();
        PageInfo pageInfo = new PageInfo<User>(all);

        return pageInfo;
    }
    @Override
    public User getUser(String userName, String password) {
        return userDao.getUser(userName,password);
    }
}
